package cn.neusoft.edu.his.demo.controller;

import cn.neusoft.edu.his.demo.common.Result;
import cn.neusoft.edu.his.demo.mapper.RoomMapper;
import cn.neusoft.edu.his.demo.po.Room;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@CrossOrigin
@Api("RoomController相关的api")
@RestController
public class RoomController {
    @Autowired
    RoomMapper roomMapper;
    @RequestMapping("/getRoom")
    public Result getRoom(Room room){
        List<Room> room1 = roomMapper.getRoom(room);
        return Result.ok(room1);
    }
    @RequestMapping("/updateRoom")
    public void updateRoom(Room room){
        int update = roomMapper.updateById(room);
    }
    @RequestMapping("/addRoom")
    public void addRomm(Room room){
        int update = roomMapper.insert(room);
    }
    @RequestMapping("deleteRoom")
    public void deleRoom(Room room){
        roomMapper.deleteById(room.getRoomId());
    }
}